package com.example.chat_demo.data;

import com.example.chat_demo.entry.User;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public  class  UserData {

    public static List<User> userList=new ArrayList<>();

    public static String[] Apartments={
            "第一公寓",
            "第二公寓",
            "第三公寓",
            "第四公寓",
            "第五公寓",
            "第六公寓",
            "第七公寓",
            "第八公寓",
            "第九公寓",
            "第十公寓",
            "第十一公寓",
    };
    public static String[] SchoolAge={
         "大一年级",
         "大二年级",
         "大三年级",
         "大四年级",
         "已毕业",
    };

    /**
     * 创建用户
     * @param userId 用户id
     */
    public  static User creatUser(String userId){
        User user = new User();
        user.setNum1(new Random().nextInt(100));
        user.setNum2(new Random().nextInt(100));
        user.setNum3(new Random().nextInt(100));
        user.setNum4(new Random().nextInt(100));
        user.setNum5(new Random().nextInt(100));
        user.setNum6(new Random().nextInt(100));
        user.setNum7(new Random().nextInt(100));
        user.setNum8(new Random().nextInt(100));
        user.setApartment(Apartments[new Random().nextInt(11)]);
        user.setId(userId);
        user.setSchoolAge(SchoolAge[new Random().nextInt(5)]);
        UserData.userList.add(user);
        return user;
    }


    /**
     * 判断 用户是否存在
     * @param userId 用户 id
     * @return 存在返回true 不存在返回false
     */
    public static  boolean  isLogin(String userId){
        for (User user : UserData.userList) {
            if (user.getId().equals(userId)){
                return true;
            }
        }
        return false;
    }




}
